// 素材库组件样式文件

// CSS 变量定义
:root {
  --material-primary-color: #409eff;
  --material-success-color: #67c23a;
  --material-warning-color: #e6a23c;
  --material-danger-color: #f56c6c;
  --material-info-color: #909399;
  --material-text-color-primary: #303133;
  --material-text-color-regular: #606266;
  --material-text-color-secondary: #909399;
  --material-text-color-placeholder: #c0c4cc;
  --material-border-color: #dcdfe6;
  --material-border-color-light: #e4e7ed;
  --material-border-color-lighter: #ebeef5;
  --material-border-color-extra-light: #f2f6fc;
  --material-background-color: #ffffff;
  --material-background-color-base: #f5f7fa;
  --material-box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);
  --material-box-shadow-light: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  --material-border-radius: 4px;
  --material-font-size-base: 14px;
  --material-font-size-small: 12px;
  --material-font-size-large: 16px;
}

// 素材库容器样式 - 兼容原项目样式
.material-library {
  height: 100%;

  // 兼容原项目的 app-container 样式
  &.app-container {
    padding: 15px;
  }

  &__container {
    height: 100%;
    
    .el-card__body {
      height: 100%;
      padding: 0;
    }
  }

  &__content {
    height: 100%;
    display: flex;
  }

  &__sidebar {
    width: 280px;
    height: 100%;
    
    .el-card {
      height: 100%;
      border: 1px solid var(--el-border-color-light);
      border-radius: 4px;
      box-shadow: var(--el-box-shadow-light);
      
      .el-card__body {
        height: 100%;
        padding: 0;
      }
    }
  }

  &__main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0;
  }

  &__toolbar {
    padding: 16px;
    border-bottom: 1px solid var(--el-border-color-light);
    background-color: var(--el-bg-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  &__table {
    flex: 1;
    overflow: hidden;
  }

  &__pagination {
    padding: 16px;
    border-top: 1px solid var(--el-border-color-light);
    background-color: var(--el-bg-color);
    display: flex;
    justify-content: center;
  }
}

// 素材组件样式 - 兼容原项目
.material-group {
  &__header {
    padding: 16px;
    border-bottom: 1px solid var(--el-border-color-light);
  }

  &__search {
    margin-bottom: 12px;
  }

  &__actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
  }

  &__table {
    .el-table {
      border: none;
    }

    .el-table__row {
      cursor: pointer;
      
      &:hover {
        background-color: var(--el-bg-color-page);
      }
    }
  }
}

// 素材表格样式 - 兼容原项目表格样式
.material-table {
  height: 100%;

  .el-table {
    height: 100%;
    
    // 继承原项目的表格样式
    thead {
      color: #303133;
      font-weight: 500;
    }
    
    th.el-table__cell {
      background-color: #f2f2f2;
    }
    
    td.el-table__cell,
    th.el-table__cell.is-leaf {
      border-bottom: 1px solid #dfe6ec;
    }
    
    &--border th.el-table__cell,
    .el-table__fixed-right-patch {
      border-bottom: 1px solid #dfe6ec;
    }
    
    &--border .el-table__cell,
    .el-table__body-wrapper.is-scrolling-left ~ .el-table__fixed {
      border-right: 1px solid #dfe6ec;
    }
  }

  &__actions {
    display: flex;
    gap: 8px;
  }

  &__content {
    max-width: 300px;
    overflow: hidden;
  }
}

// 添加素材对话框样式
.add-material-dialog {
  .el-dialog__body {
    padding: 20px;
  }

  &__form {
    .el-form-item {
      margin-bottom: 20px;
    }
  }

  &__upload {
    .el-upload__tip {
      color: var(--material-text-color-secondary);
      font-size: var(--material-font-size-small);
      margin-top: 8px;
    }
  }

  &__links {
    .link-item {
      display: flex;
      align-items: center;
      gap: 8px;
      margin-bottom: 8px;

      .el-input {
        flex: 1;
      }
    }
  }

  &__poll-options {
    .poll-option {
      display: flex;
      align-items: center;
      gap: 8px;
      margin-bottom: 8px;

      .el-input {
        flex: 1;
      }
    }

    .poll-tip {
      color: var(--material-text-color-secondary);
      font-size: var(--material-font-size-small);
      margin-top: 4px;
    }
  }
}

// 消息显示组件样式
.message-display {
  &__container {
    overflow-wrap: break-word;
    word-wrap: break-word;
    max-width: 100%;
  }

  &__content {
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  &__media {
    max-width: 200px;
    max-height: 200px;
    border-radius: var(--material-border-radius);
  }

  &__file {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--material-border-color-light);
    border-radius: var(--material-border-radius);
    background-color: var(--material-background-color-base);
  }

  &__card {
    padding: 12px;
    border: 1px solid var(--material-border-color-light);
    border-radius: var(--material-border-radius);
    background-color: var(--material-background-color);
  }

  &__link {
    padding: 12px;
    border: 1px solid var(--material-border-color-light);
    border-radius: var(--material-border-radius);
    background-color: var(--material-background-color);
    
    &-title {
      font-weight: 600;
      margin-bottom: 8px;
      color: var(--material-text-color-primary);
    }

    &-description {
      color: var(--material-text-color-regular);
      font-size: var(--material-font-size-small);
      margin-bottom: 8px;
    }

    &-url {
      color: var(--material-primary-color);
      font-size: var(--material-font-size-small);
      text-decoration: none;

      &:hover {
        text-decoration: underline;
      }
    }
  }

  &__poll {
    padding: 12px;
    border: 1px solid var(--material-border-color-light);
    border-radius: var(--material-border-radius);
    background-color: var(--material-background-color);

    &-title {
      font-weight: 600;
      margin-bottom: 12px;
      color: var(--material-text-color-primary);
    }

    &-option {
      padding: 8px 12px;
      margin-bottom: 8px;
      border: 1px solid var(--material-border-color-light);
      border-radius: var(--material-border-radius);
      background-color: var(--material-background-color-base);
      color: var(--material-text-color-regular);

      &:last-child {
        margin-bottom: 0;
      }
    }
  }
}

// 分页组件样式
.material-pagination {
  padding: 12px;

  &.hidden {
    display: none;
  }

  .el-pagination {
    justify-content: center;
  }
}

// 刷新表格组件样式
.refresh-table {
  position: absolute;
  right: 40px;
  top: 4px;
  cursor: pointer;

  &__icons {
    display: flex;
    align-items: center;
    height: 40px;
  }

  &__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--material-border-color);
    border-radius: 50%;
    margin-right: 5px;
    transition: all 0.3s;

    &:hover {
      background-color: var(--material-background-color-base);
      border-color: var(--material-primary-color);
    }

    &:last-child {
      margin-right: 0;
    }
  }
}

// 响应式设计
@media (max-width: 768px) {
  .material-library {
    &__content {
      flex-direction: column;
    }

    &__sidebar {
      width: 100%;
      height: 200px;
      border-right: none;
      border-bottom: 1px solid var(--material-border-color-light);
    }
  }

  .material-table {
    &__content {
      max-width: 200px;
    }
  }

  .message-display {
    &__media {
      max-width: 150px;
      max-height: 150px;
    }
  }
}

// 暗色主题支持
@media (prefers-color-scheme: dark) {
  :root {
    --material-text-color-primary: #e4e7ed;
    --material-text-color-regular: #cfcfcf;
    --material-text-color-secondary: #a8abb2;
    --material-text-color-placeholder: #6c6e72;
    --material-border-color: #4c4d4f;
    --material-border-color-light: #414243;
    --material-border-color-lighter: #363637;
    --material-border-color-extra-light: #2b2b2c;
    --material-background-color: #1d1e1f;
    --material-background-color-base: #1e1e1e;
  }
}

// 工具类
.material-flex {
  display: flex;
}

.material-flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.material-flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.material-text-center {
  text-align: center;
}

.material-text-left {
  text-align: left;
}

.material-text-right {
  text-align: right;
}

.material-mb-8 {
  margin-bottom: 8px;
}

.material-mb-12 {
  margin-bottom: 12px;
}

.material-mb-16 {
  margin-bottom: 16px;
}

.material-mr-8 {
  margin-right: 8px;
}

.material-mr-12 {
  margin-right: 12px;
}

.material-p-8 {
  padding: 8px;
}

.material-p-12 {
  padding: 12px;
}

.material-p-16 {
  padding: 16px;
}